package com.qqs.distributed.annotation;

import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.AdviceModeImportSelector;
import org.springframework.context.annotation.AutoProxyRegistrar;
import org.springframework.context.annotation.ImportSelector;

public class DistributedCacheConfigurationSelector extends AdviceModeImportSelector<EnableDistributedCache> {
    @Override
    protected String[] selectImports(AdviceMode adviceMode) {
        switch (adviceMode) {
            case PROXY:
                return new String[]{AutoProxyRegistrar.class.getName(),
                        ProxyDistributedCacheConfiguration.class.getName()};
            case ASPECTJ:
                return new String[]{determineDistributedCacheAspectClass()};
            default:
                return null;
        }
    }

    private String determineDistributedCacheAspectClass() {
        return AspectJDistributedCacheConfiguration.class.getName();
    }
}
